export const ParkingOrderStatusEnum = [
  { code: -1, label: '全部', status: 'Default' },
  { code: 1, label: '待支付', status: 'Warning' },
  { code: 2, label: '已完成', status: 'Success' },
  { code: 3, label: '已取消', status: 'Default' },
  { code: 4, label: '停车中', status: 'Processing' },
  { code: 5, label: '待驶离', status: 'Processing' },
  { code: 6, label: '待驶入', status: 'Processing' },
];

export const ParkingOrderStatusParse = {
  parse: (num: number) => {
    const obj = ParkingOrderStatusEnum.find((item) => item.code === num);
    if (num < 0 || obj === undefined) {
      return { code: 0, label: '未知', val: 0 };
    }
    return { ...obj, val: num };
  },
};

export const ParkingState = {
  valueEnumMap: () => {
    const map = {};
    ParkingOrderStatusEnum.forEach((item) => {
      map[item.code] = {
        text: item.label,
        status: item.status,
      };
    });
    return map;
  },
};

export const ParkingTypeMap = [
  { code: 'parking-temp', key: 1, label: '临时停车', status: 'Default' },
  { code: 'parking-share', label: '共享停车', status: 'Default' },
  { code: 1, label: '预约停车', status: 'Processing' },
  { code: 50, label: '扫码停车', status: 'Success' },
];

export const ParkingType = {
  valueEnumMap: () => {
    const map = {};
    ParkingTypeMap.forEach((item) => {
      map[item.code] = {
        text: item.label,
        status: item.status,
      };
    });
    return map;
  },
  parse: (num: number) => {
    const obj = ParkingTypeMap.find((item) => item.code === num);
    if (num < 0 || obj === undefined) {
      return { code: 0, label: '未知', val: 0 };
    }
    return { ...obj, val: num };
  },
};
